# fileName:keyboard.py
# encoding:utf-8
# usage:只监听按键按下alt+n,执行addWord.vbs脚本
# Use:双击运行

# pip3 install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com pynput
from pynput import keyboard
import subprocess

def on_activate_alt_n():
    print('<alt>+n pressed')
    # 使用subprocess避免出现黑窗口
    # subprocess执行的命令需要是应用程序exe
    # 要把.vbs需要转换成exe
    subprocess.Popen("addWord.exe", stdout = subprocess.PIPE, creationflags = subprocess.CREATE_NO_WINDOW)

with keyboard.GlobalHotKeys({'<alt>+n': on_activate_alt_n}) as h:
    h.join()
